package book.manager.mapper;

import book.manager.entity.AuthUser;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Select("select * from user where username = #{username}")
    AuthUser getUserByUsername(String username);

    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    @Insert("insert into user(username, role, password) values (#{username}, #{role}, #{password})")
    int registerUser(AuthUser user);

    @Insert("insert into student(uid, name, sex, grade) values (#{uid}, #{name}, #{sex}, #{grade})")
    int addStudentInfo(@Param("uid") int uid,
                       @Param("name") String name,
                       @Param("sex") String sex,
                       @Param("grade") String grade);
}
